package com.city.java.abnormal_videos.controller;

import com.city.java.abnormal_videos.pojo.entity.AbnormalVideos;
import com.city.java.abnormal_videos.service.AbnormalVideoService;
import com.city.java.base.response.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 异常视频控制器
 * RestController注解: 组合注解，相当于@Controller + @ResponseBody
 * Api注解: Knife4j文档中模块的显示名称
 * RequestMapping注解: 设置统一的请求路径前缀
 */
@Slf4j
@Api(tags = "12.异常视频模块")
@RestController
@RequestMapping("/api/abnormal-videos")
public class AbnormalVideoController {

    @Autowired
    private AbnormalVideoService abnormalVideoService;

    /**
     * 添加异常视频
     * PostMapping注解: 处理POST请求
     * ApiOperation注解: Knife4j文档中接口的显示名称
     */
    @PostMapping("/add")
    @ApiOperation(value = "添加异常视频", notes = "添加新异常视频信息")
    public JsonResult addAbnormalVideo(
            @ApiParam(value = "异常视频信息", required = true)
            @RequestBody AbnormalVideos abnormalVideo) {
        log.info("接收到添加异常视频请求: {}", abnormalVideo);
        return abnormalVideoService.addAbnormalVideo(abnormalVideo);
    }

    /**
     * 根据异常视频ID查询异常视频
     * GetMapping注解: 处理GET请求
     * PathVariable注解: 获取路径中的参数
     */
    @GetMapping("/select/id/{abnormalVideoId}")
    @ApiOperation(value = "根据ID查询异常视频", notes = "根据异常视频ID查询异常视频详细信息")
    public JsonResult getAbnormalVideoById(
            @ApiParam(value = "异常视频ID", required = true, example = "1")
            @PathVariable Long abnormalVideoId) {
        log.info("接收到根据ID查询异常视频请求: ID={}", abnormalVideoId);
        return abnormalVideoService.getAbnormalVideoById(abnormalVideoId);
    }

    /**
     * 根据异常记录ID查询异常视频列表
     */
    @GetMapping("/select/abnormal/{abnormalId}")
    @ApiOperation(value = "根据异常记录ID查询异常视频", notes = "根据异常记录ID查询异常视频列表")
    public JsonResult getAbnormalVideosByAbnormalId(
            @ApiParam(value = "异常记录ID", required = true, example = "1")
            @PathVariable Long abnormalId) {
        log.info("接收到根据异常记录ID查询异常视频请求: abnormalId={}", abnormalId);
        return abnormalVideoService.getAbnormalVideosByAbnormalId(abnormalId);
    }

    /**
     * 查询所有异常视频列表
     */
    @GetMapping("/quarry")
    @ApiOperation(value = "查询所有异常视频", notes = "查询所有异常视频列表")
    public JsonResult getAllAbnormalVideos() {
        log.info("接收到查询所有异常视频请求");
        return abnormalVideoService.getAllAbnormalVideos();
    }

    /**
     * 根据异常视频ID删除异常视频
     * DeleteMapping注解: 处理DELETE请求
     */
    @DeleteMapping("/delete/id/{abnormalVideoId}")
    @ApiOperation(value = "根据ID删除异常视频", notes = "根据异常视频ID删除异常视频")
    public JsonResult deleteAbnormalVideoById(
            @ApiParam(value = "异常视频ID", required = true, example = "1")
            @PathVariable Long abnormalVideoId) {
        log.info("接收到根据ID删除异常视频请求: ID={}", abnormalVideoId);
        return abnormalVideoService.deleteAbnormalVideoById(abnormalVideoId);
    }

    /**
     * 根据异常记录ID删除异常视频
     */
    @DeleteMapping("/delete/abnormal/{abnormalId}")
    @ApiOperation(value = "根据异常记录ID删除异常视频", notes = "根据异常记录ID删除异常视频")
    public JsonResult deleteAbnormalVideosByAbnormalId(
            @ApiParam(value = "异常记录ID", required = true, example = "1")
            @PathVariable Long abnormalId) {
        log.info("接收到根据异常记录ID删除异常视频请求: abnormalId={}", abnormalId);
        return abnormalVideoService.deleteAbnormalVideosByAbnormalId(abnormalId);
    }

    /**
     * 更新异常视频信息
     * PutMapping注解: 处理PUT请求
     */
    @PutMapping("/update")
    @ApiOperation(value = "更新异常视频信息", notes = "更新异常视频详细信息")
    public JsonResult updateAbnormalVideo(
            @ApiParam(value = "异常视频信息", required = true)
            @RequestBody AbnormalVideos abnormalVideo) {
        log.info("接收到更新异常视频信息请求: {}", abnormalVideo);
        return abnormalVideoService.updateAbnormalVideo(abnormalVideo);
    }
}
